package com.edu.modules.baseinfo.api;

import com.alibaba.fastjson.JSONObject;
import com.edu.modules.baseinfo.service.StudentService;
import com.edu.modules.baseinfo.vo.EvaluateListVo;
import com.edu.modules.baseinfo.vo.ResultVo;
import com.sari.common.utils.RequestContextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author kwj
 * @version 2016-08-01
 */
@CrossOrigin
@Controller
@RequestMapping(value = "student")
public class StudentApi {

    private static Logger log = LoggerFactory.getLogger(StudentApi.class);

    @Autowired
    private StudentService studentService;

    @ResponseBody
    @RequestMapping(value = "getStudentByPage")
    public JSONObject getStudentList(HttpServletRequest request) {

        JSONObject param = RequestContextUtils.readJson(request);
        return studentService.getStudentList(param);
    }

    @ResponseBody
    @RequestMapping(value = "evaluate")
    public ResultVo saveEvaluate(HttpServletRequest request){

        JSONObject param = RequestContextUtils.readJson(request);
        return studentService.saveEvaluate(param);
    }

    @ResponseBody
    @RequestMapping(value = "evaluateList")
    public EvaluateListVo getEvaluateList(String code) {

        return studentService.getEvaluateList(code);
    }

    @ResponseBody
    @RequestMapping(value = "teacherEvaluate")
    public EvaluateListVo getTeacherEvaluateList(String studentId) {

        return studentService.getTeacherEvaluateList(studentId);
    }

    @ResponseBody
    @RequestMapping(value = "lessonEvaluate")
    public ResultVo saveLessonEvaluate(HttpServletRequest request){

        JSONObject param = RequestContextUtils.readJson(request);
        return studentService.saveLessonEvaluate(param);
    }

    @ResponseBody
    @RequestMapping(value = "lessonEvaluateList")
    public EvaluateListVo getLessonEvaluateListByCode(String code) {

        return studentService.getLessonEvaluateListByCode(code);
    }

    @ResponseBody
    @RequestMapping(value = "studentEvaluate")
    public EvaluateListVo getLessonEvaluateList(String studentId) {

        return studentService.getLessonEvaluateList(studentId);
    }

    @ResponseBody
    @RequestMapping(value = "lessonPlay")
    public JSONObject getLessonPlay(String studentId) {

        return studentService.getLessonPlay(studentId);
    }

    @ResponseBody
    @RequestMapping(value = "countsStatistics")
    public JSONObject getStudentCountStatistics(HttpServletRequest request){

        JSONObject param = RequestContextUtils.readJson(request);
        return studentService.getStudentCountStatistics(param);
    }
}
